Skip to content

Conversation

itaybre
Copy link
Contributor

@itaybre itaybre commented Aug 8, 2025

Added a CI lint to validate the Package.swift files don't get out of sync.

@itaybre itaybre marked this pull request as ready for review August 8, 2025 13:02
Copy link

codecov bot commented Aug 8, 2025

❌ 12 Tests Failed:

Tests completed Failed Passed Skipped
32037 12 32025 97
View the top 3 failed test(s) by shortest run time
iOS_Swift_UITests.TopViewControllerTests::testNavigationViewController
Stack Traces | 0s run time
.../iOS-Swift/iOS-Swift-UITests/TopViewControllerTests.swift:29 - XCTAssertEqual failed: ("") is not equal to ("TableViewController")
iOS_Swift_UITests.TopViewControllerTests::testNavigationViewController
Stack Traces | 0s run time
.../iOS-Swift/iOS-Swift-UITests/TopViewControllerTests.swift:29 - XCTAssertEqual failed: ("") is not equal to ("TableViewController")
iOS_Swift_UITests.TopViewControllerTests::testPagesViewController
Stack Traces | 0s run time
.../iOS-Swift/iOS-Swift-UITests/TopViewControllerTests.swift:61 - XCTAssertEqual failed: ("") is not equal to ("RedViewController")

To view more test analytics, go to the Test Analytics Dashboard
📋 Got 3 mins? Take this short survey to help us improve Test Analytics.

@philprime
Copy link
Member

Do I understand correctly that this script is creating a diff between the two Package.swift files and then compares it to the expected diff file, because there will always be a diff between the two files (e.g. comments)?

What do you think about actually comparing the abstract syntax tree instead using e.g. SourceKitten? I am afraid the more complex the Package.swift files get over time, the more error-prone the diff will be.

Also, please be more verbose with your documentation in code an PR descriptions, so others don't need to assume the reasoning for the approach.

Copy link
Member

@philprime philprime left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See comment in PR ⬆️

@philprime
Copy link
Member

We could maybe also do it using swift package describe --type json in combination with jq

@philipphofmann
Copy link
Member

What do you think about actually comparing the abstract syntax tree instead using e.g. SourceKitten? I am afraid the more complex the Package.swift files get over time, the more error-prone the diff will be.

@philprime, I don't think it's a good idea to add an extra dependency for this simple check. I also don't think that we will actually look at the diff. We only use it to ensure we don't update one file wihout updating the other. It's just a safety guard that you have to update whenever you touch these files. When the files deviate a lot and our current approach doesn't work, we can always revisit our approach and add something more advanced. I think this approach is good enough for now.

@philprime
Copy link
Member

I don't think it's a good idea to add an extra dependency for this simple check. I also don't think that we will actually look at the diff.

If the purpose is just checking that both files are changed, then I am fine with the proposed approach. If we want to lint the actual Package.swift, I am advocating for a full validation.

@philipphofmann
Copy link
Member

I don't think it's a good idea to add an extra dependency for this simple check. I also don't think that we will actually look at the diff.

If the purpose is just checking that both files are changed, then I am fine with the proposed approach. If we want to lint the actual Package.swift, I am advocating for a full validation.

The first one, no linting. I guess we could change the workflow name to reflect this.

@itaybre
Copy link
Contributor Author

itaybre commented Aug 12, 2025

The job name might have been a bad choice, the idea is to confirm the files are in sync.
They have small differences, but for now they are the only changes needed.

cursor[bot]

This comment was marked as outdated.

@itaybre itaybre changed the title ci: Lint Package.swift differences on CI ci: Check Package.swift differences on CI Aug 12, 2025
Copy link
Member

@philipphofmann philipphofmann left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, LGTM with a comment.

@itaybre itaybre force-pushed the itay/cocoa-483-unable-to-build-with-xcode-26-for-visionos branch 2 times, most recently from fee877c to 2c9251c Compare August 14, 2025 18:45
Base automatically changed from itay/cocoa-483-unable-to-build-with-xcode-26-for-visionos to main August 14, 2025 19:28
@itaybre itaybre force-pushed the itaybre/lint_package.swift_diff branch from bda2533 to 125397f Compare August 14, 2025 20:12
@itaybre itaybre merged commit 139db8b into main Aug 15, 2025
87 of 93 checks passed
@itaybre itaybre deleted the itaybre/lint_package.swift_diff branch August 15, 2025 12:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants